package com.example.smartcity.ui.Adapter;

import android.content.Context;
import android.text.Layout;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.smartcity.R;

import java.util.ArrayList;
import java.util.List;


public class PassengerMesListViewAdapter extends ArrayAdapter{
    private int resource;
    List<String> list;
    String[] array;
    public PassengerMesListViewAdapter(@NonNull Context context, int resource, @NonNull List<String> objects,String[] array) {
        super(context, resource, objects);
        this.resource = resource;
        this.list = objects;
        this.array =array;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View view = null;
        if (position>1&&position<=3){
            view = LayoutInflater.from(getContext()).inflate(R.layout.passengeritemlayout2,parent,false);
            TextView TV_SetMessageTitle = view.findViewById(R.id.TV_SetMessageTitle2);
            EditText ED_SetMessage = view.findViewById(R.id.ED_edMessage);
            TV_SetMessageTitle.setText(array[position]);
            ED_SetMessage.setText(list.get(position));
            return view;
        }else{
            view = LayoutInflater.from(getContext()).inflate(resource,parent,false);
            TextView TV_SetMessageTitle = view.findViewById(R.id.TV_SetMessageTitle);
            TextView TV_SetMessage = view.findViewById(R.id.TV_SetMessage);
            TV_SetMessageTitle.setText(array[position]);
            TV_SetMessage.setText(list.get(position));
            return view;
        }

    }
}
